package com.derbysoft.synxisadapter.action.settings.hotel;

import com.derbysoft.core.LimitedList;
import com.derbysoft.synxisadapter.action.BaseAdapterAction;
import com.derbysoft.synxisadapter.commons.model.Hotel;
import com.derbysoft.synxisadapter.commons.repository.HotelRepository;
import com.derbysoft.synxisadapter.commons.repository.impl.HotelCondition;
import com.opensymphony.xwork2.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;

@Results(value = {
        @Result(name = Action.SUCCESS, location = "/page/settings/hotel/Query.ftl")
})
public class QueryAction extends BaseAdapterAction {

    @Autowired
    private HotelRepository hotelRepository;

    private LimitedList<Hotel> hotels = new LimitedList<Hotel>();

    private HotelCondition condition= new HotelCondition();

    public String execute() throws Exception {
        hotels = hotelRepository.findByCondition(condition, createLimit());
        paging(hotels);
        return SUCCESS;
    }

    public LimitedList<Hotel> getHotels() {
        return hotels;
    }

    public void setHotels(LimitedList<Hotel> hotels) {
        this.hotels = hotels;
    }

    public HotelCondition getCondition() {
        return condition;
    }

    public void setCondition(HotelCondition condition) {
        this.condition = condition;
    }
}
